<?php

// +---------------------------------------------+
// |     Copyright  2010 - 2018 InterPhoto       |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+

if(!defined('INTERPHOTO')) die('File not found!');

// ########################## LOAD main Smarty class #############################

require_once (BASEPATH . 'library/smarty/libs/Smarty.class.php');

class InterPhoto extends Smarty {

	function InterPhoto()
	{
   		global $mainsettings, $langs;
   		
		// Class Constructor. These automatically get set with each new instance.

		$this->Smarty();
		
		// Set up smarty environment
		$this->template_dir		= T_PATH;
		$this->compile_dir		= BASEPATH.'library/smarty/templates_c/';
		$this->config_dir		= BASEPATH.'library/smarty/configs/';
		$this->cache_dir		= BASEPATH.'library/smarty/cache/';
		
		// Assign smarty configuration variables
		$this->compile_check 	= false;

		if(!strstr($mainsettings['siteTitle'], base64_decode('SW50ZXJQaG90bw=='))){
			$mainsettings['siteTitle'] = $mainsettings['siteTitle'] . base64_decode('IC0gUG93ZXJlZCBieSBJbnRlclBob3RvIQ==');
		}
		$this->assign('baseurl', BASEURL);
		$this->assign('templateurl', T_URL);
		$this->assign('pagetitle', $mainsettings['siteTitle']);
		$this->assign('charset','UTF-8');
		$this->assign('templateheader', '<script type="text/javascript" src="includes/javascript/InterPhoto.function.js"></script>');
		$this->assign('copyrighturl',base64_decode('aHR0cDovL3d3dy53ZWVudGVjaC5jb20v'));
		$this->assign('metadescription',$mainsettings['siteMeta']);
		$this->assign('metakeywords',$mainsettings['siteKeywords']);

		$this->assign('siteCopyright',$mainsettings['siteCopyright']);
		$this->assign('siteBeian',$mainsettings['siteBeian']);

		foreach ($langs as $key => $value) {
		
			$this->assign('lan_'.$key, $value);
		
		}
		
	}
	
	/*
	*	Checks to see if template file is in the theme directory and
	*	if it isn't loads the default template file instead
	*/
	function interPlay($template) {
   		global $mainsettings, $sys_langs;
		// Security
		if (preg_match('/http:\/\//i',$template)) { return; }
		if (preg_match('/ftp:\/\//i',$template)) { return; }

		
		if (file_exists(T_PATH.$template)) {
			
			$this->display(T_PATH.$template);
		
		} else {
			$this->assign('errortitle',$sys_langs['template'].$sys_langs['error']);
			$this->assign('errors',$sys_langs['notemplatefile']);

			if (file_exists(T_PATH.'error.tpl')) {
				$this->display(T_PATH.'error.tpl');
			}else{
				echo 'Template file "error.tpl" is missing.';
			}
			exit();
		}
		
	}
	
	
}


?>